using LiJ.Common.Extention;
using System.Collections.Generic;
using System.Xml;

namespace LiJ.Pay.WeiXin.Cash.Mos
{
	public class WxPayQueryRedResp : WxPayBaseResp
	{
		/// <summary>   
		///    商户订单号 必填 String(28) 商户使用查询API填写的商户单号的原路返回
		/// </summary>  
		public string mch_billno
		{
			get;
			set;
		}

		/// <summary>   
		///    红包单号 必填 String(32) 使用API发放现金红包时返回的红包单号
		/// </summary>  
		public string detail_id
		{
			get;
			set;
		}

		/// <summary>   
		///    红包状态 必填 string(16) SENDING:发放中 SENT:已发放待领取 FAILED：发放失败 RECEIVED:已领取 RFUND_ING:退款中 REFUND:已退款
		/// </summary>  
		public string status
		{
			get;
			set;
		}

		/// <summary>   
		///    发放类型 必填 String(32) API:通过API接口发放 UPLOAD:通过上传文件方式发放 ACTIVITY:通过活动方式发放
		/// </summary>  
		public string send_type
		{
			get;
			set;
		}

		/// <summary>   
		///    红包类型 必填 String(32) GROUP:裂变红包 NORMAL:普通红包
		/// </summary>  
		public string hb_type
		{
			get;
			set;
		}

		/// <summary>   
		///    红包个数 必填 int 红包个数
		/// </summary>  
		public string total_num
		{
			get;
			set;
		}

		/// <summary>   
		///    红包金额 必填 int 红包总金额（单位分）
		/// </summary>  
		public string total_amount
		{
			get;
			set;
		}

		/// <summary>   
		///    失败原因 可空 String(32) 发送失败原因
		/// </summary>  
		public string reason
		{
			get;
			set;
		}

		/// <summary>   
		///    红包发送时间 必填 20:00:00 String(32)
		/// </summary>  
		public string send_time
		{
			get;
			set;
		}

		/// <summary>   
		///    红包退款时间 可空 23:03:00 String(32) 红包的退款时间（如果其未领取的退款）
		/// </summary>  
		public string refund_time
		{
			get;
			set;
		}

		/// <summary>   
		///    红包退款金额 可空 Int 红包退款金额
		/// </summary>  
		public int refund_amount
		{
			get;
			set;
		}

		/// <summary>   
		///    祝福语 可空 String(128) 祝福语
		/// </summary>  
		public string wishing
		{
			get;
			set;
		}

		/// <summary>   
		///    活动描述 可空 String(256) 活动描述，低版本微信可见
		/// </summary>  
		public string remark
		{
			get;
			set;
		}

		/// <summary>   
		///    活动名称 可空 String(32) 发红包的活动名称
		/// </summary>  
		public string act_name
		{
			get;
			set;
		}

		/// <summary>   
		///    裂变红包领取列表 可空 裂变红包的领取列表
		/// </summary>  
		public List<WxPayRedItemMo> hblist
		{
			get;
			set;
		}

		/// <summary>
		/// 格式化自身属性部分
		/// </summary>
		protected override void FormatPropertiesFromMsg()
		{
			base.FormatPropertiesFromMsg();
			this.mch_billno = base["mch_billno"];
			this.detail_id = base["detail_id"];
			this.status = base["status"];
			this.send_type = base["send_type"];
			this.hb_type = base["hb_type"];
			this.total_num = base["total_num"];
			this.total_amount = base["total_amount"];
			this.reason = base["reason"];
			this.send_time = base["send_time"];
			this.refund_time = base["refund_time"];
			this.refund_amount = base["refund_amount"].ToInt32(0);
			this.wishing = base["wishing"];
			this.remark = base["remark"];
			this.act_name = base["act_name"];
			if (!string.IsNullOrEmpty(base["hblist"]))
			{
				XmlNodeList childNodes = base.RespXml.FirstChild["hblist"].ChildNodes;
				List<WxPayRedItemMo> list = new List<WxPayRedItemMo>(childNodes.Count);
				foreach (XmlNode item in childNodes)
				{
					if (!item.HasChildNodes)
					{
						break;
					}
					WxPayRedItemMo wxPayRedItemMo = new WxPayRedItemMo();
					WxPayRedItemMo wxPayRedItemMo2 = wxPayRedItemMo;
					XmlElement xmlElement = item["amount"];
					wxPayRedItemMo2.amount = (((xmlElement != null) ? xmlElement.InnerText : null) ?? string.Empty).ToInt32(0);
					WxPayRedItemMo wxPayRedItemMo3 = wxPayRedItemMo;
					XmlElement xmlElement2 = item["openid"];
					wxPayRedItemMo3.openid = ((xmlElement2 != null) ? xmlElement2.InnerText : null);
					WxPayRedItemMo wxPayRedItemMo4 = wxPayRedItemMo;
					XmlElement xmlElement3 = item["rcv_time"];
					wxPayRedItemMo4.rcv_time = ((xmlElement3 != null) ? xmlElement3.InnerText : null);
					list.Add(wxPayRedItemMo);
				}
				this.hblist = list;
			}
		}
	}
}
